/**   
* @Title: GatewayApplication.java
* @Package me.cloud
* @Description: TODO
* @author xaoyaoyao
* @date 2018年11月21日 上午11:24:56
* @version V1.0   
*/
package me.cloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.web.filter.reactive.HiddenHttpMethodFilter;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilterChain;

import reactor.core.publisher.Mono;

/**
 * @ClassName: GatewayApplication
 * @Description: TODO
 * @author xaoyaoyao
 * @date 2018年11月21日 上午11:24:56
 * 
 */
@SpringBootApplication
public class GatewayApplication {

	public static void main(String[] args) {
		SpringApplication.run(GatewayApplication.class, args);
	}

	@Bean
	public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
		// 打开oschina首页
		return builder.routes().route(t -> t.path("/oschina").and().uri("https://www.oschina.net/")).build();
	}

	@Bean
	public HiddenHttpMethodFilter hiddenHttpMethodFilter() {
		return new HiddenHttpMethodFilter() {
			@Override
			public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
				return chain.filter(exchange);
			}
		};
	}

}
